package cn.pink.centersrv;

import cn.pink.common.support.tools.cache.CacheTool;
import cn.pink.core.NodeType;
import cn.pink.core.Port;
import cn.pink.core.Service;
import cn.pink.core.config.CacheConfig;
import cn.pink.core.gen.proxy.DistrClass;
import cn.pink.core.gen.proxy.DistrMethod;
import cn.pink.core.scheduler.ScheduleMethod;
import cn.pink.core.support.Log;

/**
 * @Author: pink
 * @Date: 2022/6/17 15:52
 */
@DistrClass(nodeType = NodeType.CENTER)
public class CenterService extends Service {
    public CenterService(Port port) {
        super(port);
    }

    @Override
    public Object getId() {
        return RPCProxy.CenterServiceProxy.DIST_NAME;
    }

    @DistrMethod
    public void defaultHandler(String str) {

    }

    /**
     * 定时打印 在线人数
     */
    @ScheduleMethod("*/30 * * * * ?")
    public void printOnlineNum() {
        int num = CacheTool.getInstance().getCache(CacheConfig.SESSION).size();
        Log.center.info("---------------------------------- online num {} ----------------------------------", num);
    }

    /**
     * 定时打印 节点状态
     */
//    @ScheduleMethod("*/30 * * * * ?")
    public void printNodeStatus() {
    }
}
